const { GuildMember, WebhookClient, MessageEmbed } = require('discord.js');

module.exports = {
  name: 'guildMemberAdd',
  /**
   *
   * @param {GuildMember} member
   */
  execute(member) {
    const { user, guild } = member;

    member.roles.add('982311338716057600');

    const Welcomer = new WebhookClient({
      id: '982303048992948295',
      token:
        'uN5IJ7DAKUrcTosBLM1xpKHcR1P71gHxOfHOxYM7Cr-XNvvfAhBvyHRsXJJXoOoJrcqe',
    });

    const Welcome = new MessageEmbed()
      .setColor('GREEN')
      .setAuthor({
        name: user.tag,
        iconURL: user.avatarURL({ dynamic: true, size: 512 }),
      })
      .setThumbnail(user.avatarURL({ dynamic: true, size: 512 }))
      .setDescription(
        `
      Welcome ${member} the the **${guild.name}**!\n
      Account Created <t:${parseInt(user.createdTimestamp / 1000)}:R>\n
      Latest Member Count: **${guild.memberCount}**`
      )
      .setFooter({ text: `ID: ${user.id}` });

    Welcomer.send({ embeds: [Welcome] });
  },
};
